package com.usian.wemedia.wemedia.controller;

import com.usian.apis.service.wemedia.WemediaControllerUpload;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.*;
import com.usian.model.media.pojos.WmNews;
import com.usian.wemedia.wemedia.service.MediaServiceUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/wemedia/upload")
public class MediaControlerUpload implements WemediaControllerUpload {
    @Autowired
    private MediaServiceUpload mediaServiceUpload;

    @RequestMapping("upload")
    @Override
    public ResponseResult upload(MultipartFile multipartFile) {
        return mediaServiceUpload.upload(multipartFile);
    }

    @RequestMapping("findPage")
    @Override
    public ResponseResult findpage(@RequestBody WmMaterialDto wmMaterialDto) {
        return mediaServiceUpload.findpage(wmMaterialDto);
    }

    @RequestMapping("del/{id}")
    @Override
    public ResponseResult del(@PathVariable Integer id) {
        return mediaServiceUpload.del(id);
    }

    @RequestMapping("updateNews")
    @Override
    public ResponseResult updateNews(@RequestBody WmNews wmNews) {
        return mediaServiceUpload.updateNews(wmNews);
    }

    @RequestMapping("collect/{id}")
    @Override
    public ResponseResult collect(@PathVariable Integer id) {
        return mediaServiceUpload.collect(id,1);
    }

    @RequestMapping("cancel_collect/{id}")
    @Override
    public ResponseResult cancel_collect(@PathVariable Integer id) {
        return mediaServiceUpload.collect(id,0);
    }

    @RequestMapping("list")
    @Override
    public ResponseResult list(@RequestBody  WmNewsPageReqDto dto) {
        return mediaServiceUpload.newsfindPage(dto);
    }

    @RequestMapping("submitnews")
    @Override
    public ResponseResult submitnews(@RequestBody WmNewsDto wmNewsDto) {
        if(wmNewsDto.getStatus()==1){
            return mediaServiceUpload.submitnews(wmNewsDto,1);
        }else{
            return mediaServiceUpload.submitnews(wmNewsDto,0);
        }
    }

    @RequestMapping("findById/{id}")
    @Override
    public WmNews findById(@PathVariable(value = "id") Integer id) {
        return mediaServiceUpload.findById(id);
    }

    @RequestMapping("findNews")
    @Override
    public ResponseResult findNews(@RequestBody NewsAuthDto newsAuthDto) {
        return mediaServiceUpload.findNews(newsAuthDto);
    }

    @RequestMapping("one/{id}")
    @Override
    public ResponseResult one(@PathVariable Integer id) {
        return mediaServiceUpload.one(id);
    }

    @RequestMapping("auth_pass")
    @Override
    public ResponseResult auth_pass(@RequestBody WmNewsAuthDto wmNewsAuthDto) {
        return mediaServiceUpload.auth_pass(wmNewsAuthDto);
    }

    @RequestMapping("down_or_up")
    @Override
    public ResponseResult down_or_up(@RequestBody WmNews wmNews) {
        return mediaServiceUpload.down_or_up(wmNews);
    }

    @RequestMapping("findAll")
    @Override
    public List<WmNews> findAll() {
        return mediaServiceUpload.findAll();
    }







}
